package com.yznote.cloudesk.user.controller;

import com.yznote.cloudesk.common.pojo.Bar;
import com.yznote.cloudesk.common.pojo.Result;
import com.yznote.cloudesk.common.tokenShare.YTokenShare;
import com.yznote.cloudesk.user.server.BarServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/bar")
@Api(tags = "底部状态栏")

public class BarController {
    @Autowired
    BarServer barServer;
    @Autowired
    YTokenShare yTokenShare;

    @GetMapping("/getBarList")
    @ApiOperation("查询状态栏列表")
    public Result getBarList(){
        Long userId = yTokenShare.get().getUserId();
        List<Bar> list = barServer.getBarList(userId);
        return Result.success(list);
    }

    @GetMapping("/insetBar")
    @ApiOperation("增加Bar")
    public Result insertBar(@RequestParam Long fileId){
        Long userId = yTokenShare.get().getUserId();
        barServer.insertBar(userId,fileId);
        return Result.success(null);
    }

//    @GetMapping("/insetBarList")
//    @ApiOperation("初始化增加Bar")
//    public void insetBarList(@RequestParam Long userId){
//
//    }

    @GetMapping("/removeBar")
    @ApiOperation("移除Bar")
    public Result removeBar(@RequestParam Integer index){
        Long userId = yTokenShare.get().getUserId();
        barServer.removeBar(userId,index);
        return Result.success(null);
    }

    @GetMapping("/swapBar")
    @ApiOperation("交换两个bar的位置")
    public Result swapBar(@RequestParam Integer index1, @RequestParam Integer index2){
        Long userId = yTokenShare.get().getUserId();
        barServer.swapBar(userId,index1,index2);
        return Result.success(null);
    }



}
